#!/usr/bin/env python3
#-*-encoding:utf-8-*-

import os

#清空控制台
def clear():
    print("\033c",end="")

# 二分查找法
#运行时间 O(log N)
def findSmallest(arr):
    smallest = arr[0]
    smallest_index = 0
    for i in range(1,len(arr)):
        if arr[i] < smallest :
            smallest = arr[i]
            smallest_index = i
    return smallest_index

def selecttionSort(arr):
    newArr = []
    for i in range(len(arr)):
        smallest = findSmallest(arr)
        newArr.append(arr.pop(smallest))
    return newArr
# ----------------------------------------------
clear()  #清屏
mlist = [5,3,1,-2,7,9]
print(selecttionSort(mlist))


